package com.heima.controller;

import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author itheima
 * @since 2022-07-14
 */
@RestController
@RequestMapping("test")
public class TestController {
    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @SneakyThrows
    @GetMapping("/hello")
    public String test() {
        kafkaTemplate.send("itcast-topic","这是黑马").get();
        return "ok";
    }
}
